package cn.edu.sjtu.stap.graph;

/**
 * Interface of graph.
 * 
 * @author William
 * 
 */
public interface IGraph {
    /**
     * Get all the nodes in this graph.
     * 
     * @return a set of nodes.
     */
    public IGraphComponentSet getNodes();

    /**
     * Get all the edges in this graph.
     * 
     * @return a set of edges.
     */
    public IGraphComponentSet getEdges();

    /**
     * Get the size of all nodes.
     * 
     * @return an int indicating the size of nodes.
     */
    public int getSizeOfNodes();

    /**
     * Get the size of all edges.
     * 
     * @return an int indicating the size of edges.
     */
    public int getSizeOfEdges();

    /**
     * Traverse all the components in this graph with random order. The nodes
     * will traversed first, then the edges.
     * 
     * @param v
     *            GraphVisitor perform the tasks for all the components in the
     *            traverse.
     */
    public void traverse(GraphVisitor v);

    /**
     * The random order to traverse the nodes of this graph. Traverse all the
     * nodes of this graph with a random order. It starts with the first node in
     * the node set.
     */
    public static final int NO_ORDER_TRAVERSE = 1;

    /**
     * The depth-first order. Traverse all the nodes of this graph in the
     * depth-first search order. It starts with the first node in the node set.
     */
    public static final int DFS_TRAVERSE = 2;

    /**
     * The breadth-first order. Traverse all the nodes of this graph in the
     * breadth-first search order. It starts with the first node in the node
     * set.
     */
    public static final int BFS_TRAVERSE = 3;

    /**
     * Traverse all the graph nodes in this graph according to a certain order.
     * 
     * @param v
     *            GraphVisitor perform the tasks for all the nodes in the
     *            traverse.
     * @param visitOrder
     *            The order to traverse.
     */
    public void traverse(GraphVisitor v, int visitOrder);
}
